var express = require('express');
var mysql = require('../db/mysqlDB.js');
var router = express.Router();

router.get('/',function(req,res,next){
	res.render('login');
});
router.get('/main',function(req,res,next){
	//console.log(req.cookies);
	if(req.cookies.login){
		res.render('main',{
			id:req.cookies.login.id
		});
	}else{
		res.render('login');
	}
});
router.get('/resource',function(req,res,next){
	if(req.cookies.login){
		mysql.getSomeresone('id',req.query.id,function(result){
			res.render('resource',{
				id:req.cookies.login.id,
				res:result[0],
				time:result[0].time.toString().substring(11,15)
			})
		})
	}else{
		res.render('login');
	}
});
router.get('/feedback',function(req,res,next){
	if(req.cookies.login){
		res.render('feedback',{
			id:req.cookies.login.id
		});
	}else{
		res.render('login');
	}
});
router.get('/onlinehelp',function(req,res,next){
	if(req.cookies.login){
		res.render('onlinehelp',{
			id:req.cookies.login.id
		});
	}else{
		res.render('login');
	}
});
router.get('/mine',function(req,res,next){
	if(req.cookies.login){
		res.render('mine',{
			id:req.cookies.login.id
		});
	}else{
		res.render('login');
	}
});
router.get('/upload',function(req,res,next){
	if(req.cookies.login){
		res.render('upload',{
			id:req.cookies.login.id
		});
	}else{
		res.render('login');
	}
});
router.get('/loading',function(req,res,next){
	res.render('loading');
});
router.get('/admin',function(req,res,next){
	if(req.cookies.login){
		res.render('admin',{
			id:req.cookies.login.id
		});
	}else{
		res.render('login');
	}
});
module.exports = router;